LOADCT
The LOADCT procedure loads one of the predefined IDL color tables. These color tables are defined in the file colors1.tbl
, located in the \resource\colors
subdirectory of the main IDL directory, unless the FILE keyword is specified. The selected colortable is loaded into the COLORS common block as both the “current” and “original” colortable. If the current device has fewer than 256 colors, the color table data is interpolated to cover the number of colors in the device.
This routine is written in the IDL language. Its source code can be found in the file loadct.pro
in the lib
subdirectory of the IDL distribution.
Obtaining the Color Tables
All of the IDL color-table procedures maintain the current color table in a common block called COLORS, defined as follows:
COMMON COLORS, R_orig, G_orig, B_orig, R_curr, G_curr, B_curr
The variables are integer vectors of length equal to the number of color indices. Your program can access these variables by defining the common block. The convention is that routines that modify the current color table should read it from R_orig, G_orig, and B_orig, then load the color table using TVLCT and leave the resulting color table in R_curr, G_curr, and B_curr.
Examples
The following example introduces using LOADCT.
Tip: If you are running IDL on a TrueColor display, set DEVICE, DECOMPOSED = 0
before your first color table related routine is used within an IDL session or program.
-
View a list of IDL’s tables and their related indices by calling LOADCT without an argument:
LOADCT
The list of color tables appears in the Output Log:
When running LOADCT without an argument, it will prompt you to enter the number of one of the color tables at the IDL command line.
-
Enter in the number 5 at the
Enter table number:
prompt:Enter table number: 5
The following text is displayed in the Output Log:
% LOADCT: Loading table STD GAMMA-II
If you already know the number of the pre-defined color table you want, you can load a color table by providing that number as the first input argument to LOADCT.
-
Load in color table number 13 (RAINBOW):
LOADCT, 13
The following text is displayed in the Output Log:
% LOADCT: Loading table RAINBOW
-
View the color table in a simple image display:
TV, DIST(300)
Note: To see the organization of the colors associated with each color table, use XLOADCT.
Syntax
LOADCT [, Table] [, BOTTOM=value] [, FILE=string] [, GET_NAMES=variable] [, NCOLORS=value] [, RGB_TABLE=value] [, /SILENT]
Arguments
Table
The number of the pre-defined color table to load. (See Loading a Default Color Table.) If this value is omitted, a menu of the available tables is printed and the user is prompted to enter a table number.
Keywords
BOTTOM
The first color index to use. LOADCT will use color indices from BOTTOM to BOTTOM+NCOLORS-1. The default is BOTTOM=0.
FILE
Set this keyword to the name of a colortable file to be used instead of the file colors1.tbl
. See MODIFYCT to create and modify colortable files.
GET_NAMES
Set this keyword to a named variable in which the names of the color tables are returned as a string array. No changes are made to the color table.
NCOLORS
The number of colors to use. The default is all available colors (this number is stored in the system variable !D.TABLE_SIZE).
RGB_TABLE
Set this keyword to a named variable in which to return the desired color table as an [NCOLORS, 3] array. If this keyword is set, then the color table is not loaded into the display, but is returned to the user. In addition, if RGB_TABLE is set then SILENT is also set to true.
SILENT
If this keyword is set, the Color Table message is suppressed.
Version History
Original |
Introduced |
6.4 |
Added the RGB_TABLE keyword |
See Also